﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Mvc2Ng.Web.UI.Models;
using Mvc2Ng.Web.NgLib.Extensions.Attributes;
using Mvc2Ng.Web.UI.Controllers;

namespace Mvc2Ng.Web.UI.Controllers {

  [NgController]
  public class ProjectController : AngularJsController {

    [NgController("~/Views/Project/js/index.js")]
    public ActionResult Index() {
      return View();
    }

    [NgController("~/Views/Project/js/opus.js")]
    public ActionResult Opus() {
      return View();
    }

    [NgController("~/Views/Project/js/project.js")]
    public ActionResult Project() {
      return View();
    }

    [NgController("~/Views/Project/js/newproject.js")]
    public ActionResult NewProject() {
      return View();
    }

    [HttpPost]
    [NgController("~/Views/Project/js/newproject.js")]
    public JsonResult NewProject(NewProject newProject) {
      if (ModelState.IsValid) {
        return Json(new { msg = "OK" });
      }
      return Json(new { msg = "Error" });
    }

    public ActionResult EditProject() {
      return View();
    }

    [HttpPost]
    [NgController("~/Views/Project/js/editproject.js")]
    public ActionResult EditProject(EditProject editProject) {
      if (ModelState.IsValid && editProject.BasePrice > 0) {
        return Json(new { msg = "OK" });
      }
      return new HttpStatusCodeResult(400, "Validation Error");
    }

  }
}
